package 洛谷.二分答案;

import java.io.*;
import java.util.HashMap;
import java.util.Map;

public class test1 {
    //A-C=B. C=m
    static int[] q=new int[1000005];
    public static void main(String[] args) {
        Reader sc=new Reader();
        HashMap<Integer,Integer> mp=new HashMap<>();
        int n,m;
        n=sc.nextInt();
        m=sc.nextInt();

        for(int i=0;i<n;i++){
            q[i]=sc.nextInt();
            mp.put(i,q[i]);
        }


        int cnt=0;
       for(int i=0;i<n;i++){
           for(Map.Entry<Integer,Integer> entry:mp.entrySet()){
               Integer key = entry.getKey();
               Integer value=entry.getValue();
                if(i!=key&&q[i]+m==value){
                    cnt++;
                }
           }
       }
        System.out.println(cnt);

    }
}
class Reader{
    public BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public StreamTokenizer st=new StreamTokenizer(br);

    void Token(){
        try {
            st.nextToken();
        }catch (Exception e){

        }
    }

    public int nextInt(){
        Token();
        return (int)st.nval;
    }
}